package com.monitor.action.user;

import java.io.PrintWriter;

import com.monitor.action.MonitorActionSupport;
import com.monitor.po.RemoteSms;
import com.monitor.service.RemoteSmsService;
import com.monitor.util.Pager;

public class RemoteSmsAction extends MonitorActionSupport {

	private static final long serialVersionUID = -6856437281925959749L;
	private int cPage;
	private Pager<RemoteSms> rsmss;
	private RemoteSmsService remoteSmsService;
	private long uid;
	private long rid;
	private String content;
	private String phoneStr;
	private String ridStr;
	private int sentSmsCount;
	private int unSentSmsCount;

	@Override
	public String execute() throws Exception {
		cPage = cPage < 1 ? 1 : cPage;
		// rsmss = remoteSmsService.getRemoteSmsByUid(uid, cPage,
		// Constants.DEFAULT_PAGESIEZE);
		sentSmsCount = remoteSmsService.getSentRemoteSmsCount(uid);
		unSentSmsCount = remoteSmsService.getUnSentRemoteSmsCount(uid);
		return SUCCESS;
	}

	public void deleteRemoteSms() throws Exception {
		PrintWriter out = getWriter();
		boolean success = remoteSmsService.deleteRemoteSmsById(rid);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public void deleteMultiRemoteSms() throws Exception {
		PrintWriter out = getWriter();
		boolean success = remoteSmsService.deleteRemoteSms(ridStr);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public void addRemoteSms() throws Exception {
		PrintWriter out = getWriter();
		boolean success = remoteSmsService.addRemoteSms(phoneStr, content, uid);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public int getcPage() {
		return cPage;
	}

	public void setcPage(int cPage) {
		this.cPage = cPage;
	}

	public Pager<RemoteSms> getRsmss() {
		return rsmss;
	}

	public void setRsmss(Pager<RemoteSms> rsmss) {
		this.rsmss = rsmss;
	}

	public RemoteSmsService getRemoteSmsService() {
		return remoteSmsService;
	}

	public void setRemoteSmsService(RemoteSmsService remoteSmsService) {
		this.remoteSmsService = remoteSmsService;
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public long getRid() {
		return rid;
	}

	public void setRid(long rid) {
		this.rid = rid;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getPhoneStr() {
		return phoneStr;
	}

	public void setPhoneStr(String phoneStr) {
		this.phoneStr = phoneStr;
	}

	public String getRidStr() {
		return ridStr;
	}

	public void setRidStr(String ridStr) {
		this.ridStr = ridStr;
	}

	public int getSentSmsCount() {
		return sentSmsCount;
	}

	public void setSentSmsCount(int sentSmsCount) {
		this.sentSmsCount = sentSmsCount;
	}

	public int getUnSentSmsCount() {
		return unSentSmsCount;
	}

	public void setUnSentSmsCount(int unSentSmsCount) {
		this.unSentSmsCount = unSentSmsCount;
	}

}
